﻿using System;
using System.Collections.Generic;
using System.Globalization;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using JTLeigh.Commerce.Spencer.Features.ProductImages.Common.Entities;
using JTLeigh.Commerce.Spencer.Core.Testing;

namespace JTLeigh.Commerce.Spencer.Features.ProductImages.Common.UnitTests.Entities
{

	/// <summary>
	/// Unit tests for the <see cref="LocalizedProductImageView"/> class.
	/// </summary>
	[TestClass]
	public class LocalizedProductImageViewFixture
	{

		#region Methods

		/// <summary>
		/// Ensures <see cref="LocalizedProductImageView"/> returns default values for its 
		/// localizable fields when its constructor is passed a <see langword="null"/> value 
		/// instead of a <see cref="ProductImageViewLocalization"/> object.
		/// </summary>
		[TestMethod]
		public void TestLocalizedProductImageViewOperationWithLocalization()
		{
			ProductImageView view;
			ProductImageViewLocalization localization;
			LocalizedProductImageView localizedView;

			view = new ProductImageView
			{
				ViewId = Guid.NewGuid(),
				WellKnownViewCode = 1,
				DisplayOrder = 2,
				DefaultName = "defaultName",
			};
			localization = new ProductImageViewLocalization
			{
				ViewId = Guid.NewGuid(),
				CultureId = TestConstants.CultureId.EnglishCanada,
				Name = "localizedName",
			};
			localizedView = new LocalizedProductImageView(view, localization);

			Assert.AreEqual(view.ViewId, localizedView.ViewId);
			Assert.AreEqual(view.WellKnownViewCode, localizedView.WellKnownViewCode);
			Assert.AreEqual(view.DisplayOrder, localizedView.DisplayOrder);
			Assert.AreEqual(localization.Name, localizedView.Name);
		}

		/// <summary>
		/// Ensures <see cref="LocalizedProductImageView"/> returns localized values for its 
		/// localizable fields when its constructor is passed a <see cref="ProductImageViewLocalization"/> 
		/// object.
		/// </summary>
		[TestMethod]
		public void TestLocalizedProductImageViewOperationWithoutLocalization()
		{
			ProductImageView view;
			LocalizedProductImageView localizedView;

			view = new ProductImageView
			{
				ViewId = Guid.NewGuid(),
				WellKnownViewCode = 1,
				DisplayOrder = 2,
				DefaultName = "defaultName",
			};
			localizedView = new LocalizedProductImageView(view, null);

			Assert.AreEqual(view.ViewId, localizedView.ViewId);
			Assert.AreEqual(view.WellKnownViewCode, localizedView.WellKnownViewCode);
			Assert.AreEqual(view.DisplayOrder, localizedView.DisplayOrder);
			Assert.AreEqual(view.DefaultName, localizedView.Name);
		}

		#endregion // Methods

	}

}
